package com.muyu.system.controller;


import com.muyu.common.core.domain.Result;
import com.muyu.common.core.utils.poi.ExcelUtil;
import com.muyu.common.core.web.controller.BaseController;
import com.muyu.common.log.annotation.Log;
import com.muyu.common.log.enums.BusinessType;
import com.muyu.system.domain.DanmoVipPackage;
import com.muyu.system.service.IDanmoVipPackageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;

/**
 * vip套餐包Controller
 * 
 * @author yl
 * @date 2025-06-10
 */
@RestController
@RequestMapping("/package")
public class DanmoVipPackageController extends BaseController
{
    @Autowired
    private IDanmoVipPackageService danmoVipPackageService;

    /**
     * 查询vip套餐包列表
     */
//    @RequiresPermissions("system:package:list")
    @PostMapping("/list")
    public Result<List<DanmoVipPackage>> list(@RequestBody DanmoVipPackage danmoVipPackage)
    {

        List<DanmoVipPackage> list = danmoVipPackageService.selectDanmoVipPackageList(danmoVipPackage);
        return Result.success(list);
    }

    /**
     * 导出vip套餐包列表
     */
//    @RequiresPermissions("system:package:export")
    @Log(title = "vip套餐包", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DanmoVipPackage danmoVipPackage)
    {
        List<DanmoVipPackage> list = danmoVipPackageService.selectDanmoVipPackageList(danmoVipPackage);
        ExcelUtil<DanmoVipPackage> util = new ExcelUtil<DanmoVipPackage>(DanmoVipPackage.class);
        util.exportExcel(response, list, "vip套餐包数据");
    }

    /**
     * 获取vip套餐包详细信息
     */
//    @RequiresPermissions("system:package:query")
    @GetMapping(value = "/{id}")
    public Result getInfo(@PathVariable("id") Long id)
    {
        return success(danmoVipPackageService.selectDanmoVipPackageById(id));
    }

    /**
     * 新增vip套餐包
     */
//    @RequiresPermissions("system:package:add")
    @Log(title = "vip套餐包", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public Result add(@RequestBody DanmoVipPackage danmoVipPackage)
    {
        return toAjax(danmoVipPackageService.insertDanmoVipPackage(danmoVipPackage));
    }

    /**
     * 修改vip套餐包
     */
//    @RequiresPermissions("system:package:edit")
    @Log(title = "vip套餐包", businessType = BusinessType.UPDATE)
    @PostMapping("edit")
    public Result edit(@RequestBody DanmoVipPackage danmoVipPackage)
    {
        return toAjax(danmoVipPackageService.updateDanmoVipPackage(danmoVipPackage));
    }

    /**
     * 删除vip套餐包
     */
//    @RequiresPermissions("system:package:remove")
    @Log(title = "vip套餐包", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public Result remove(@PathVariable Long[] ids)
    {
        return toAjax(danmoVipPackageService.deleteDanmoVipPackageByIds(ids));
    }

    /**
     * 对象
     */
    @PostMapping("/packages")
    public DanmoVipPackage packages(@RequestBody DanmoVipPackage danmoVipPackage){
        return danmoVipPackageService.packages(danmoVipPackage);
    }


    @PostMapping("packagesList")
    public Result<Map<String, Object>> packagesList(@RequestBody DanmoVipPackage danmoVipPackage){
        return danmoVipPackageService.packagesList(danmoVipPackage);
    }
}
